package cn.ssj.controller;

import cn.ssj.entity.News;
import cn.ssj.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/9/5 0005.
 */
@RestController
@EnableAutoConfiguration
public class NewsController extends BaseController<News,Integer> {

    @Autowired
    private NewsService service;
    @RequestMapping("/back/addNews")
    public String add(News entity) {
        return super.add(entity);
    }

    @RequestMapping("/back/updateNews")
    public String update(News entity) {
        return super.update(entity);
    }

    @RequestMapping("/back/deleteNews")
    public String delete(@RequestParam("ids[]")Integer[] ids) {
        return super.delete(ids);
    }

    @RequestMapping("/back/queryAllNewsByPage")
    public String queryAllByPage(Integer pageNumber) {
        return super.queryAllByPage(pageNumber);
    }
    @RequestMapping("/front/queryNewsById")
    public News queryNewsById(Integer id){
        if(null==id){
            return null;
        }
        return service.queryOne(id);
    }
}
